# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[Item.__init__(self, *args, **kw)
self.network = network
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dbeec>}
nname: 36
n 36(None)[return False
]:
	i: 15(), 35()
	o: 

nname: 35
n 35(None)[]:
	i: 0(f)
	o: 36()

nname: 15
n 15(None)[return self.network == other.network
]:
	i: 0(t)
	o: 36()

nname: 0
n 0(isinstance(other, CryptoItem))[]:
	i: 
	o: 15(t), 35(f)

nname: 0
n 0(None)[if isinstance(other, CryptoItem):
	return self.network == other.network
return False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76da14c>}
nname: 64
n 64(None)[]:
	i: 15(), 38()
	o: 

nname: 38
n 38(None)[return cmp(type(self), type(other))
]:
	i: 0(f)
	o: 64()

nname: 15
n 15(None)[return cmp(self.network, other.network)
]:
	i: 0(t)
	o: 64()

nname: 0
n 0(isinstance(other, CryptoItem))[]:
	i: 
	o: 15(t), 38(f)

nname: 0
n 0(None)[if isinstance(other, CryptoItem):
	return cmp(self.network, other.network)
else:
	return cmp(type(self), type(other))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76da1ec>}
nname: 6
n 6(None)[def __init__(self, network, *args, **args):
	Item.__init__(self, *args, **kw)
	self.network = network

def __eq__(self, other):
	if isinstance(other, CryptoItem):
		return self.network == other.network
	return False

def __cmp__(self, other):
	if isinstance(other, CryptoItem):
		return cmp(self.network, other.network)
	else:
		return cmp(type(self), type(other))

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76db9ac>}
nname: 0
n 0(None)[return self.get_item_list('options0_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f076c>}
nname: 0
n 0(None)[return self.get_item_list('options1_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f08cc>}
nname: 0
n 0(None)[return self.get_item_list('options2_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f074c>}
nname: 0
n 0(None)[return self.get_item_list('options3_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f086c>}
nname: 121
n 121(None)[self._connecting_config = None
Menu.__init__(self, choices=[], **kw)
self.wizard_menu = None
self.connect_win = None
self.loading_win = None
self.eventhandler = WifiSelectMenuEventHandler(self)
self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
def self._getitems_keywords['options0_list']():
	return self.get_item_list('options0_list')

def self._getitems_keywords['options1_list']():
	return self.get_item_list('options1_list')

def self._getitems_keywords['options2_list']():
	return self.get_item_list('options2_list')

def self._getitems_keywords['options3_list']():
	return self.get_item_list('options3_list')

self.set_items([], 'options0_list')
self.set_items([], 'options1_list')
self.set_items([], 'options2_list')
self.set_items([], 'options3_list')
self.active_list = 'options2_list'
self.list_configs()
return None
]:
	i: 70(), 100(), 119(AE)
	o: 

nname: 119
n 119(None)[]:
	i: 90(f)
	o: 121(AE)

nname: 100
n 100(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 90(t)
	o: 121()

nname: 90
n 90(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 100(t), 119(f)

nname: 70
n 70(None)[self.wn.set_scanning(True)
]:
	i: 0(try)
	o: 121()

nname: 0
n 0(None)[self.on_device_connected_task = Task(self._on_device_connected)
self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
self.wn = WyNetwork()
self.wn.wn_dev.attach(self)
]:
	i: 
	o: 70(try), 90(except)

nname: 90
n 90(None)[except Exception, e:
	PRINT_EXCEPTION(e)
self._connecting_config = None
Menu.__init__(self, choices=[], **kw)
self.wizard_menu = None
self.connect_win = None
self.loading_win = None
self.eventhandler = WifiSelectMenuEventHandler(self)
self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
def self._getitems_keywords['options0_list']():
	return self.get_item_list('options0_list')

def self._getitems_keywords['options1_list']():
	return self.get_item_list('options1_list')

def self._getitems_keywords['options2_list']():
	return self.get_item_list('options2_list')

def self._getitems_keywords['options3_list']():
	return self.get_item_list('options3_list')

self.set_items([], 'options0_list')
self.set_items([], 'options1_list')
self.set_items([], 'options2_list')
self.set_items([], 'options3_list')
self.active_list = 'options2_list'
self.list_configs()
return None
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.on_device_connected_task = Task(self._on_device_connected)
self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
self.wn = WyNetwork()
self.wn.wn_dev.attach(self)
try:
	self.wn.set_scanning(True)
]:
	i: 
	o: 90()

nname: 0
n 0(None)[self.on_device_connected_task = Task(self._on_device_connected)
self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
self.wn = WyNetwork()
self.wn.wn_dev.attach(self)
try:
	self.wn.set_scanning(True)
except Exception, e:
	PRINT_EXCEPTION(e)
self._connecting_config = None
Menu.__init__(self, choices=[], **kw)
self.wizard_menu = None
self.connect_win = None
self.loading_win = None
self.eventhandler = WifiSelectMenuEventHandler(self)
self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
def self._getitems_keywords['options0_list']():
	return self.get_item_list('options0_list')

def self._getitems_keywords['options1_list']():
	return self.get_item_list('options1_list')

def self._getitems_keywords['options2_list']():
	return self.get_item_list('options2_list')

def self._getitems_keywords['options3_list']():
	return self.get_item_list('options3_list')

self.set_items([], 'options0_list')
self.set_items([], 'options1_list')
self.set_items([], 'options2_list')
self.set_items([], 'options3_list')
self.active_list = 'options2_list'
self.list_configs()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dde2c>}
nname: 0
n 0(None)[self[self.active_list].selected.execute()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76daeac>}
nname: 67
n 67(None)[self.wn.wn_dev.detach(self)
Menu.stop(self)
]:
	i: 16(), 46(), 65(AE)
	o: 

nname: 65
n 65(None)[]:
	i: 36(f)
	o: 67(AE)

nname: 46
n 46(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 36(t)
	o: 67()

nname: 36
n 36(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 46(t), 65(f)

nname: 16
n 16(None)[self.wn.set_scanning(False)
]:
	i: 0(try)
	o: 67()

nname: 0
n 0(None)[log.debug('Detach from wynetwork signals and set_scanning(False)')
]:
	i: 
	o: 16(try), 36(except)

nname: 36
n 36(None)[except Exception, e:
	PRINT_EXCEPTION(e)
self.wn.wn_dev.detach(self)
Menu.stop(self)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug('Detach from wynetwork signals and set_scanning(False)')
try:
	self.wn.set_scanning(False)
]:
	i: 
	o: 36()

nname: 0
n 0(None)[log.debug('Detach from wynetwork signals and set_scanning(False)')
try:
	self.wn.set_scanning(False)
except Exception, e:
	PRINT_EXCEPTION(e)
self.wn.wn_dev.detach(self)
Menu.stop(self)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd58c>}
nname: 106
n 106(None)[cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
self.set_items(cfg_list, 'options2_list')
self.active_list = 'options2_list'
return None
]:
	i: 0(AL), 105()
	o: 

nname: 105
n 105(None)[]:
	i: 18(AF), 34()
	o: 106()

nname: 34
n 34(None)[for config in self.wn.get_configs():
log.debug('config %s', config.name)
cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
]:
	i: 18(for)
	o: 105()

nname: 18
n 18(None)[]:
	i: 0(loop)
	o: 34(for), 105(AF)

nname: 0
n 0(None)[cfg_list = []
self._connecting_config = None
]:
	i: 
	o: 18(loop), 106(AL)

nname: 106
n 106(None)[cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
self.set_items(cfg_list, 'options2_list')
self.active_list = 'options2_list'
return None
]:
	i: 34()
	o: 

nname: 34
n 34(None)[for config in self.wn.get_configs():
	log.debug('config %s', config.name)
	cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
]:
	i: 0(for)
	o: 106()

nname: 0
n 0(None)[cfg_list = []
self._connecting_config = None
]:
	i: 
	o: 34(for)

nname: 106
n 106(None)[cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
self.set_items(cfg_list, 'options2_list')
self.active_list = 'options2_list'
return None
]:
	i: 0()
	o: 

nname: 0
n 0(None)[cfg_list = []
self._connecting_config = None
for config in self.wn.get_configs():
	log.debug('config %s', config.name)
	cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
]:
	i: 
	o: 106()

nname: 0
n 0(None)[cfg_list = []
self._connecting_config = None
for config in self.wn.get_configs():
	log.debug('config %s', config.name)
	cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
self.set_items(cfg_list, 'options2_list')
self.active_list = 'options2_list'
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddbec>}
nname: 245
n 245(None)[]:
	i: 212(), 244()
	o: 

nname: 244
n 244(None)[]:
	i: 206(f)
	o: 245()

nname: 212
n 212(None)[cw = BigConfirmWindow(config.name, buttons)
cw.show()
]:
	i: 206(t)
	o: 245()

nname: 206
n 206(buttons)[]:
	i: 99(), 205()
	o: 212(t), 244(f)

nname: 205
n 205(None)[]:
	i: 87(f)
	o: 206()

nname: 99
n 99(None)[buttons.append(Button(_('Edit'), False))
buttons[-1].connect(self.edit_config, config)
buttons.append(Button(_('Delete'), False))
buttons[-1].connect(self.delete_config, config)
]:
	i: 87(t)
	o: 206()

nname: 87
n 87(config.is_removable())[]:
	i: 31(), 86()
	o: 99(t), 205(f)

nname: 86
n 86(None)[]:
	i: 0(f)
	o: 87()

nname: 31
n 31(None)[buttons.append(Button(_('Connect'), True))
buttons[-1].connect(self.active_config, config)
]:
	i: 0(t)
	o: 87()

nname: 0
n 0(config.is_valid())[log.debug(config)
buttons = []
]:
	i: 
	o: 31(t), 86(f)

nname: 206
n 206(None)[if buttons:
	cw = BigConfirmWindow(config.name, buttons)
	cw.show()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug(config)
buttons = []
if config.is_valid():
	buttons.append(Button(_('Connect'), True))
	buttons[-1].connect(self.active_config, config)
if config.is_removable():
	buttons.append(Button(_('Edit'), False))
	buttons[-1].connect(self.edit_config, config)
	buttons.append(Button(_('Delete'), False))
	buttons[-1].connect(self.delete_config, config)
]:
	i: 
	o: 206()

nname: 0
n 0(None)[log.debug(config)
buttons = []
if config.is_valid():
	buttons.append(Button(_('Connect'), True))
	buttons[-1].connect(self.active_config, config)
if config.is_removable():
	buttons.append(Button(_('Edit'), False))
	buttons[-1].connect(self.edit_config, config)
	buttons.append(Button(_('Delete'), False))
	buttons[-1].connect(self.delete_config, config)
if buttons:
	cw = BigConfirmWindow(config.name, buttons)
	cw.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd98c>}
nname: 0
n 0(None)[return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddeac>}
nname: 187
n 187(None)[return None
]:
	i: 136(), 166(), 185(AE)
	o: 

nname: 185
n 185(None)[]:
	i: 156(f)
	o: 187(AE)

nname: 166
n 166(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 156(t)
	o: 187()

nname: 156
n 156(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 166(t), 185(f)

nname: 136
n 136(None)[self.wn.active_config(config)
]:
	i: 0(try)
	o: 187()

nname: 0
n 0(None)[self.loading_win = LoadingWindow()
self.loading_win.show()
log.debug(config)
self._connecting_config = config
title = _('Connecting to %(net)s') % dict(net=config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=180)
]:
	i: 
	o: 136(try), 156(except)

nname: 156
n 156(None)[except Exception, e:
	PRINT_EXCEPTION(e)
return None
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.loading_win = LoadingWindow()
self.loading_win.show()
log.debug(config)
self._connecting_config = config
title = _('Connecting to %(net)s') % dict(net=config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=180)
try:
	self.wn.active_config(config)
]:
	i: 
	o: 156()

nname: 0
n 0(None)[self.loading_win = LoadingWindow()
self.loading_win.show()
log.debug(config)
self._connecting_config = config
title = _('Connecting to %(net)s') % dict(net=config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=180)
try:
	self.wn.active_config(config)
except Exception, e:
	PRINT_EXCEPTION(e)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd2ac>}
nname: 0
n 0(None)[log.debug(config)
louie_send('on_%s_blur' % self._active_list, self)
self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=config)
self.wizard_menu.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dafcc>}
nname: 72
n 72(None)[]:
	i: 61(AE)
	o: 

nname: 61
n 61(None)[self.list_configs()
]:
	i: 0(finally), 57()
	o: 72(AE)

nname: 57
n 57(None)[]:
	i: 6(), 36(), 55(AE)
	o: 61()

nname: 55
n 55(None)[]:
	i: 26(f)
	o: 57(AE)

nname: 36
n 36(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 26(t)
	o: 57()

nname: 26
n 26(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 3(except)
	o: 36(t), 55(f)

nname: 6
n 6(None)[self.wn.delete_config(config)
]:
	i: 3(try)
	o: 57()

nname: 3
n 3(None)[]:
	i: 0(ASF)
	o: 6(try), 26(except)

nname: 0
n 0(None)[]:
	i: 
	o: 3(ASF2), 61(finally)

nname: 72
n 72(None)[]:
	i: 61(AE)
	o: 

nname: 61
n 61(None)[self.list_configs()
]:
	i: 0(finally), 26()
	o: 72(AE)

nname: 26
n 26(None)[except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 3()
	o: 61()

nname: 3
n 3(None)[try:
	self.wn.delete_config(config)
]:
	i: 0(ASF2)
	o: 26()

nname: 0
n 0(None)[]:
	i: 
	o: 3(ASF2), 61(finally)

nname: 72
n 72(None)[]:
	i: 61(AE)
	o: 

nname: 61
n 61(None)[self.list_configs()
]:
	i: 0(finally), 3()
	o: 72(AE)

nname: 3
n 3(None)[try:
	self.wn.delete_config(config)
except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 0(ASF2)
	o: 61()

nname: 0
n 0(None)[]:
	i: 
	o: 3(ASF2), 61(finally)

nname: 61
n 61(None)[finally:
	self.list_configs()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	self.wn.delete_config(config)
except Exception, e:
	PRINT_EXCEPTION(e)
]:
	i: 
	o: 61()

nname: 0
n 0(None)[try:
	self.wn.delete_config(config)
except Exception, e:
	PRINT_EXCEPTION(e)
finally:
	self.list_configs()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddcec>}
nname: 0
n 0(None)[log.debug(config)
def _do_delete():
	try:
		self.wn.delete_config(config)
	except Exception, e:
		PRINT_EXCEPTION(e)
	finally:
		self.list_configs()

cw = ConfirmWindow(_('Are you sure ?'), confirm_action=_do_delete)
cw.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76daf4c>}
nname: 0
n 0(None)[louie_send('on_%s_blur' % self._active_list, self)
self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=None)
self.wizard_menu.show()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dafac>}
nname: 0
n 0(None)[return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddfcc>}
nname: 33
n 33(None)[log.debug(self._connecting_config)
self.connect_win.hide()
title = _('Connected to %(net)s') % dict(net=self._connecting_config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=3)
self.hide()
return None
]:
	i: 15(), 32()
	o: 

nname: 32
n 32(None)[]:
	i: 0(f)
	o: 33()

nname: 15
n 15(None)[self.loading_win.hide()
]:
	i: 0(t)
	o: 33()

nname: 0
n 0(self.loading_win is not None)[]:
	i: 
	o: 15(t), 32(f)

nname: 0
n 0(None)[if self.loading_win is not None:
	self.loading_win.hide()
log.debug(self._connecting_config)
self.connect_win.hide()
title = _('Connected to %(net)s') % dict(net=self._connecting_config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=3)
self.hide()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd66c>}
nname: 64
n 64(None)[self.wizard_menu.hide()
self.list_configs()
return None
]:
	i: 28(), 63()
	o: 

nname: 63
n 63(None)[]:
	i: 0(f)
	o: 64()

nname: 28
n 28(None)[MessageWindow(_('Error during configuration'), button=None).show(5)
]:
	i: 0(t)
	o: 64()

nname: 0
n 0(config == None)[log.debug('config = %s', config)
]:
	i: 
	o: 28(t), 63(f)

nname: 0
n 0(None)[log.debug('config = %s', config)
if config == None:
	MessageWindow(_('Error during configuration'), button=None).show(5)
self.wizard_menu.hide()
self.list_configs()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd4ec>}
nname: 0
n 0(None)[return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddbec>}
nname: 0
n 0(None)[log.debug(self._connecting_config)
self.connect_win.hide()
title = _('Disconnected from %(net)s') % dict(net=self._connecting_config.name)
self.connect_win = MessageWindow(title, button=None)
def self.connect_win.eventhandler.event_stop(event):
	return None

self.connect_win.show(timeout=3)
self.list_configs()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddb2c>}
nname: 0
n 0(None)[log.debug(device)
self.on_device_connected_task.args = (device,)
self.on_device_connected_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dae6c>}
nname: 0
n 0(None)[log.debug(device)
self.on_device_connection_failed_task.args = (device,)
self.on_device_connection_failed_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76daf6c>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dabec>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dacec>}
nname: 6
n 6(None)[__doc__ = ' To manage configurations (select, active or delete a config) '
def __init__(self, **kw):
	self.on_device_connected_task = Task(self._on_device_connected)
	self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
	self.wn = WyNetwork()
	self.wn.wn_dev.attach(self)
	try:
		self.wn.set_scanning(True)
	except Exception, e:
		PRINT_EXCEPTION(e)
	self._connecting_config = None
	Menu.__init__(self, choices=[], **kw)
	self.wizard_menu = None
	self.connect_win = None
	self.loading_win = None
	self.eventhandler = WifiSelectMenuEventHandler(self)
	self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
	def self._getitems_keywords['options0_list']():
		return self.get_item_list('options0_list')

	def self._getitems_keywords['options1_list']():
		return self.get_item_list('options1_list')

	def self._getitems_keywords['options2_list']():
		return self.get_item_list('options2_list')

	def self._getitems_keywords['options3_list']():
		return self.get_item_list('options3_list')

	self.set_items([], 'options0_list')
	self.set_items([], 'options1_list')
	self.set_items([], 'options2_list')
	self.set_items([], 'options3_list')
	self.active_list = 'options2_list'
	self.list_configs()
	return None

def execute_selected(self):
	self[self.active_list].selected.execute()

def stop(self):
	log.debug('Detach from wynetwork signals and set_scanning(False)')
	try:
		self.wn.set_scanning(False)
	except Exception, e:
		PRINT_EXCEPTION(e)
	self.wn.wn_dev.detach(self)
	Menu.stop(self)

def list_configs(self):
	cfg_list = []
	self._connecting_config = None
	for config in self.wn.get_configs():
		log.debug('config %s', config.name)
		cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
	cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
	self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
	self.set_items(cfg_list, 'options2_list')
	self.active_list = 'options2_list'
	return None

def select_config(self, config):
	log.debug(config)
	buttons = []
	if config.is_valid():
		buttons.append(Button(_('Connect'), True))
		buttons[-1].connect(self.active_config, config)
	if config.is_removable():
		buttons.append(Button(_('Edit'), False))
		buttons[-1].connect(self.edit_config, config)
		buttons.append(Button(_('Delete'), False))
		buttons[-1].connect(self.delete_config, config)
	if buttons:
		cw = BigConfirmWindow(config.name, buttons)
		cw.show()

def active_config(self, config):
	self.loading_win = LoadingWindow()
	self.loading_win.show()
	log.debug(config)
	self._connecting_config = config
	title = _('Connecting to %(net)s') % dict(net=config.name)
	self.connect_win = MessageWindow(title, button=None)
	def self.connect_win.eventhandler.event_stop(event):
		return None

	self.connect_win.show(timeout=180)
	try:
		self.wn.active_config(config)
	except Exception, e:
		PRINT_EXCEPTION(e)
	return None

def edit_config(self, config):
	log.debug(config)
	louie_send('on_%s_blur' % self._active_list, self)
	self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=config)
	self.wizard_menu.show()

def delete_config(self, config):
	log.debug(config)
	def _do_delete():
		try:
			self.wn.delete_config(config)
		except Exception, e:
			PRINT_EXCEPTION(e)
		finally:
			self.list_configs()

	cw = ConfirmWindow(_('Are you sure ?'), confirm_action=_do_delete)
	cw.show()

def create_config(self):
	louie_send('on_%s_blur' % self._active_list, self)
	self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=None)
	self.wizard_menu.show()
	return None

def _on_device_connected(self, device):
	if self.loading_win is not None:
		self.loading_win.hide()
	log.debug(self._connecting_config)
	self.connect_win.hide()
	title = _('Connected to %(net)s') % dict(net=self._connecting_config.name)
	self.connect_win = MessageWindow(title, button=None)
	def self.connect_win.eventhandler.event_stop(event):
		return None

	self.connect_win.show(timeout=3)
	self.hide()
	return None

def _wizard_callback(self, config):
	log.debug('config = %s', config)
	if config == None:
		MessageWindow(_('Error during configuration'), button=None).show(5)
	self.wizard_menu.hide()
	self.list_configs()
	return None

def _on_device_connection_failed(self, device):
	log.debug(self._connecting_config)
	self.connect_win.hide()
	title = _('Disconnected from %(net)s') % dict(net=self._connecting_config.name)
	self.connect_win = MessageWindow(title, button=None)
	def self.connect_win.eventhandler.event_stop(event):
		return None

	self.connect_win.show(timeout=3)
	self.list_configs()
	return None

def onDeviceConnected(self, device):
	log.debug(device)
	self.on_device_connected_task.args = (device,)
	self.on_device_connected_task.start(1)

def onDeviceConnectionFailed(self, device):
	log.debug(device)
	self.on_device_connection_failed_task.args = (device,)
	self.on_device_connection_failed_task.start(1)

def onDeviceConnecting(self, device):
	pass

def onDeviceDisconnected(self, device):
	pass

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76da3ec>}
nname: 0
n 0(None)[return self.get_item_list('options0_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb767ea4c>}
nname: 0
n 0(None)[return self.get_item_list('options1_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb767e86c>}
nname: 0
n 0(None)[return self.get_item_list('options2_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb767e02c>}
nname: 0
n 0(None)[return self.get_item_list('options3_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb767ee6c>}
nname: 649
n 649(None)[log.debug('current_config %s', self._current_config)
return None
]:
	i: 623(JA), 644(), 648()
	o: 

nname: 648
n 648(None)[]:
	i: 546(f)
	o: 649()

nname: 644
n 644(None)[]:
	i: 567&603(f)
	o: 649()

nname: 623
n 623(None)[log.error('Editing 802.11 config but no wireless device found. Cancel configuration')
return None
]:
	i: 567&603(t)
	o: 649(JA)

nname: 567&603
n 567&603(self._previous_config and self._previous_config['networkType'] == '802.11')[log.debug('no 802.11 devices, set_ethernet()')
self._current_config.set_ethernet()
]:
	i: 546(t)
	o: 623(t), 644(f)

nname: 546
n 546('802.11' not in self.wn.availables_networkType())[]:
	i: 489(JA), 521(), 545()
	o: 567&603(t), 648(f)

nname: 545
n 545(None)[]:
	i: 0&460(f)
	o: 546()

nname: 521
n 521(None)[log.error('previous_config %s is not valid. Cancel configuration', config)
return None
]:
	i: 476(f)
	o: 546()

nname: 489
n 489(None)[log.debug('editing %s (not implemented)', config.name)
self._previous_config = config
]:
	i: 476(t)
	o: 546(JA)

nname: 476
n 476(config.is_valid())[]:
	i: 0&460(t)
	o: 489(t), 521(f)

nname: 0&460
n 0&460(config and isinstance(config, WyNetworkConfig))[self.eventhandler = WifiSelectMenuEventHandler(self)
Menu.__init__(self, name='NetworkWizardMenu', type='network_connect', universe='setup')
self.wn = WyNetwork()
self._callback = callback
self.wifi_menu = None
self.eventhandler = WifiSelectMenuEventHandler(self)
self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
def self._getitems_keywords['options0_list']():
	return self.get_item_list('options0_list')

def self._getitems_keywords['options1_list']():
	return self.get_item_list('options1_list')

def self._getitems_keywords['options2_list']():
	return self.get_item_list('options2_list')

def self._getitems_keywords['options3_list']():
	return self.get_item_list('options3_list')

self.set_items([], 'options0_list')
self.set_items([], 'options1_list')
self.set_items([], 'options2_list')
self.set_items([], 'options3_list')
self.active_list = 'options0_list'
self.config_updaters = {'networkType': self._ask_type, 'ipConfigType': self._ask_mode, 'key': self._ask_key, 'essid': self._ask_essid, 'interface': self._ask_interface, 'authType': self._ask_key_type, 'cipher': self._ask_key_type, 'keyMgmt': self._ask_key_type, 'ipAddress': self._ask_ip_params, 'netmask': self._ask_ip_params, 'gateway': self._ask_ip_params}
self._previous_config = None
self._current_config = self.wn.new_config()
log.debug('create new config')
]:
	i: 
	o: 476(t), 545(f)

nname: 0&460
n 0&460(None)[self.eventhandler = WifiSelectMenuEventHandler(self)
Menu.__init__(self, name='NetworkWizardMenu', type='network_connect', universe='setup')
self.wn = WyNetwork()
self._callback = callback
self.wifi_menu = None
self.eventhandler = WifiSelectMenuEventHandler(self)
self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
def self._getitems_keywords['options0_list']():
	return self.get_item_list('options0_list')

def self._getitems_keywords['options1_list']():
	return self.get_item_list('options1_list')

def self._getitems_keywords['options2_list']():
	return self.get_item_list('options2_list')

def self._getitems_keywords['options3_list']():
	return self.get_item_list('options3_list')

self.set_items([], 'options0_list')
self.set_items([], 'options1_list')
self.set_items([], 'options2_list')
self.set_items([], 'options3_list')
self.active_list = 'options0_list'
self.config_updaters = {'networkType': self._ask_type, 'ipConfigType': self._ask_mode, 'key': self._ask_key, 'essid': self._ask_essid, 'interface': self._ask_interface, 'authType': self._ask_key_type, 'cipher': self._ask_key_type, 'keyMgmt': self._ask_key_type, 'ipAddress': self._ask_ip_params, 'netmask': self._ask_ip_params, 'gateway': self._ask_ip_params}
self._previous_config = None
self._current_config = self.wn.new_config()
log.debug('create new config')
if config and isinstance(config, WyNetworkConfig):
	if config.is_valid():
		log.debug('editing %s (not implemented)', config.name)
		self._previous_config = config
	else:
		log.error('previous_config %s is not valid. Cancel configuration', config)
		return None
if '802.11' not in self.wn.availables_networkType():
	log.debug('no 802.11 devices, set_ethernet()')
	self._current_config.set_ethernet()
	if self._previous_config and self._previous_config['networkType'] == '802.11':
		log.error('Editing 802.11 config but no wireless device found. Cancel configuration')
		return None
log.debug('current_config %s', self._current_config)
return None
]:
	i: 
	o: 

self.nodes: {'0&460': <unpyclib.structure.node instance at 0xb767ebec>}
nname: 0
n 0(None)[Menu.show(self, hide_previous_menu)
self.start()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dafec>}
nname: 75
n 75(None)[]:
	i: 37(), 61()
	o: 

nname: 61
n 61(None)[self.config_wizard.next()
]:
	i: 0(f)
	o: 75()

nname: 37
n 37(None)[self.set_type(self._previous_config['networkType'])
]:
	i: 0(t)
	o: 75()

nname: 0
n 0(self._previous_config)[self.config_wizard = self.configurator()
self.config_wizard.next()
]:
	i: 
	o: 37(t), 61(f)

nname: 0
n 0(None)[self.config_wizard = self.configurator()
self.config_wizard.next()
if self._previous_config:
	self.set_type(self._previous_config['networkType'])
else:
	self.config_wizard.next()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd7ac>}
nname: 0
n 0(None)[self[self.active_list].selected.execute()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dafec>}
nname: 55
n 55(None)[self.set_items(item.browse(), browse_list_name)
self.active_list = browse_list_name
]:
	i: 0(AL), 54()
	o: 

nname: 54
n 54(None)[]:
	i: 22(AF), 32()
	o: 55()

nname: 32
n 32(None)[for l in self.available_choices:
self.set_items([], l)
]:
	i: 22(for)
	o: 54()

nname: 22
n 22(None)[]:
	i: 0(loop)
	o: 32(for), 54(AF)

nname: 0
n 0(None)[self.set_items([item], 'main_list')
]:
	i: 
	o: 22(loop), 55(AL)

nname: 55
n 55(None)[self.set_items(item.browse(), browse_list_name)
self.active_list = browse_list_name
]:
	i: 32()
	o: 

nname: 32
n 32(None)[for l in self.available_choices:
	self.set_items([], l)
]:
	i: 0(for)
	o: 55()

nname: 0
n 0(None)[self.set_items([item], 'main_list')
]:
	i: 
	o: 32(for)

nname: 55
n 55(None)[self.set_items(item.browse(), browse_list_name)
self.active_list = browse_list_name
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.set_items([item], 'main_list')
for l in self.available_choices:
	self.set_items([], l)
]:
	i: 
	o: 55()

nname: 0
n 0(None)[self.set_items([item], 'main_list')
for l in self.available_choices:
	self.set_items([], l)
self.set_items(item.browse(), browse_list_name)
self.active_list = browse_list_name
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd28c>}
nname: 116
n 116(None)[]:
	i: 67(), 94(), 114(AE)
	o: 

nname: 114
n 114(None)[]:
	i: 84(f)
	o: 116(AE)

nname: 94
n 94(None)[log.debug('config_wizard STOP')
]:
	i: 84(t)
	o: 116()

nname: 84
n 84(<dummy_ex3> EXC_MATCH StopIteration)[]:
	i: 0(except)
	o: 94(t), 114(f)

nname: 67
n 67(None)[self.config_wizard.next()
]:
	i: 0(try)
	o: 116()

nname: 0
n 0(None)[log.debug('selected network: %s', network)
self._current_config.set_network(network)
log.debug('config: %s', self._current_config)
self.wifi_menu.hide()
]:
	i: 
	o: 67(try), 84(except)

nname: 84
n 84(None)[except StopIteration:
	log.debug('config_wizard STOP')
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug('selected network: %s', network)
self._current_config.set_network(network)
log.debug('config: %s', self._current_config)
self.wifi_menu.hide()
try:
	self.config_wizard.next()
]:
	i: 
	o: 84()

nname: 0
n 0(None)[log.debug('selected network: %s', network)
self._current_config.set_network(network)
log.debug('config: %s', self._current_config)
self.wifi_menu.hide()
try:
	self.config_wizard.next()
except StopIteration:
	log.debug('config_wizard STOP')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd78c>}
nname: 325
n 325(None)[]:
	i: 215(), 293()
	o: 

nname: 293
n 293(None)[log.debug('got name %s', self._current_config.name)
self._save_config()
]:
	i: 229(), 264()
	o: 325()

nname: 264
n 264(None)[log.debug('Asking for a name')
self._ask_name()
yield None
]:
	i: 219(f)
	o: 293()

nname: 229
n 229(None)[log.debug('Take name from previous_config')
self._current_config.name = self._previous_config.name
]:
	i: 219(t)
	o: 293()

nname: 219
n 219(self._previous_config)[]:
	i: 178(f)
	o: 229(t), 264(f)

nname: 215
n 215(None)[]:
	i: 178(t)
	o: 325()

nname: 178
n 178(invalids)[invalids = self._current_config.invalids_keys()
log.debug('config.configurator STOP: invalids=%s', invalids)
]:
	i: 0(AL), 177()
	o: 215(t), 219(f)

nname: 177
n 177(None)[]:
	i: 59(AF), 158()
	o: 178()

nname: 158
n 158(None)[log.debug('Got %s', invalid)
]:
	i: 88(), 156(AE)
	o: 177()

nname: 156
n 156(None)[]:
	i: 111(f), 121()
	o: 158(AE)

nname: 121
n 121(None)[#, e
log.error('Error while filling %s', invalid)
PRINT_EXCEPTION(e)
continue
]:
	i: 111(t)
	o: 156()

nname: 111
n 111(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 66(except)
	o: 121(t), 156(f)

nname: 88
n 88(None)[self.config_updaters[invalid]()
yield None
]:
	i: 66(try)
	o: 158()

nname: 66
n 66(None)[for invalid in cur_conf_configurator:
log.debug('Asking %s', invalid)
]:
	i: 59(for)
	o: 88(try), 111(except)

nname: 59
n 59(None)[]:
	i: 0(loop)
	o: 66(for), 177(AF)

nname: 0
n 0(None)[log.debug('init')
cur_conf_configurator = self._current_config.configurator()
cur_conf_configurator.next()
yield None
log.debug('start !')
]:
	i: 
	o: 59(loop), 178(AL)

nname: 325
n 325(None)[]:
	i: 219(), 178(t)
	o: 

nname: 219
n 219(None)[if self._previous_config:
	log.debug('Take name from previous_config')
	self._current_config.name = self._previous_config.name
else:
	log.debug('Asking for a name')
	self._ask_name()
	yield None
log.debug('got name %s', self._current_config.name)
self._save_config()
]:
	i: 178(f)
	o: 325()

nname: 325
n 325(None)[]:
	i: 219(), 178(t)
	o: 

nname: 178
n 178(invalids)[invalids = self._current_config.invalids_keys()
log.debug('config.configurator STOP: invalids=%s', invalids)
]:
	i: 0(AL), 59(AF), 158()
	o: 325(t), 219(f)

nname: 158
n 158(None)[log.debug('Got %s', invalid)
]:
	i: 88(), 111(AE)
	o: 178()

nname: 111
n 111(None)[except Exception, e:
	log.error('Error while filling %s', invalid)
	PRINT_EXCEPTION(e)
	continue
]:
	i: 66(except)
	o: 158(AE)

nname: 88
n 88(None)[self.config_updaters[invalid]()
yield None
]:
	i: 66(try)
	o: 158()

nname: 66
n 66(None)[for invalid in cur_conf_configurator:
log.debug('Asking %s', invalid)
]:
	i: 59(for)
	o: 88(try), 111(except)

nname: 59
n 59(None)[]:
	i: 0(loop)
	o: 66(for), 178(AF)

nname: 0
n 0(None)[log.debug('init')
cur_conf_configurator = self._current_config.configurator()
cur_conf_configurator.next()
yield None
log.debug('start !')
]:
	i: 
	o: 59(loop), 178(AL)

updateEdges Exception 111
postorder Exception 111
nname: 178
n 178(None)[invalids = self._current_config.invalids_keys()
log.debug('config.configurator STOP: invalids=%s', invalids)
if not invalids:
	if self._previous_config:
		log.debug('Take name from previous_config')
		self._current_config.name = self._previous_config.name
	else:
		log.debug('Asking for a name')
		self._ask_name()
		yield None
	log.debug('got name %s', self._current_config.name)
	self._save_config()
]:
	i: 0(AL), 59(AF), 158()
	o: 

simplifyConsecutive Exception 111
self.nodes: {0: <unpyclib.structure.node instance at 0xb76f082c>, 66: <unpyclib.structure.node instance at 0xb76f030c>, 178: <unpyclib.structure.node instance at 0xb76f0d0c>, 59: <unpyclib.structure.node instance at 0xb76f02cc>, 158: <unpyclib.structure.node instance at 0xb76f0d2c>}
simplifyConsecutive Exception 111
nname: 52
n 52(None)[]:
	i: 3(), 30(), 50(AE)
	o: 

nname: 50
n 50(None)[]:
	i: 20(f)
	o: 52(AE)

nname: 30
n 30(None)[log.debug('fill_config STOP')
]:
	i: 20(t)
	o: 52()

nname: 20
n 20(<dummy_ex3> EXC_MATCH StopIteration)[]:
	i: 0(except)
	o: 30(t), 50(f)

nname: 3
n 3(None)[self.config_wizard.next()
]:
	i: 0(try)
	o: 52()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 20(except)

nname: 20
n 20(None)[except StopIteration:
	log.debug('fill_config STOP')
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	self.config_wizard.next()
]:
	i: 
	o: 20()

nname: 0
n 0(None)[try:
	self.config_wizard.next()
except StopIteration:
	log.debug('fill_config STOP')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddd6c>}
nname: 70
n 70(None)[self._callback(self._current_config)
]:
	i: 16(), 49(), 68(AE)
	o: 

nname: 68
n 68(None)[]:
	i: 39(f)
	o: 70(AE)

nname: 49
n 49(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 39(t)
	o: 70()

nname: 39
n 39(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 49(t), 68(f)

nname: 16
n 16(None)[self.wn.save_config(self._current_config)
]:
	i: 0(try)
	o: 70()

nname: 0
n 0(None)[log.debug('Configuration done. saving...')
]:
	i: 
	o: 16(try), 39(except)

nname: 39
n 39(None)[except Exception, e:
	PRINT_EXCEPTION(e)
self._callback(self._current_config)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug('Configuration done. saving...')
try:
	self.wn.save_config(self._current_config)
]:
	i: 
	o: 39()

nname: 0
n 0(None)[log.debug('Configuration done. saving...')
try:
	self.wn.save_config(self._current_config)
except Exception, e:
	PRINT_EXCEPTION(e)
self._callback(self._current_config)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd5ec>}
nname: 104
n 104(None)[]:
	i: 25(), 65(), 103()
	o: 

nname: 103
n 103(None)[]:
	i: 52(f)
	o: 104()

nname: 65
n 65(None)[self.wifi_menu = WifiSelectMenu(callback=self._wifi_callback)
self.wifi_menu.show()
]:
	i: 52(t)
	o: 104()

nname: 52
n 52(type == '802.11')[]:
	i: 0(f)
	o: 65(t), 103(f)

nname: 25
n 25(None)[self._current_config.set_ethernet()
self._next_key()
]:
	i: 0(t)
	o: 104()

nname: 0
n 0(type == '802.3')[self._current_config['networkType'] = type
]:
	i: 
	o: 25(t), 52(f)

nname: 0
n 0(None)[self._current_config['networkType'] = type
if type == '802.3':
	self._current_config.set_ethernet()
	self._next_key()
else:
	if type == '802.11':
		self.wifi_menu = WifiSelectMenu(callback=self._wifi_callback)
		self.wifi_menu.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd52c>}
nname: 0
n 0(None)[log.error('User does not provide name. Cancel configuration !')
self.kbd.hide()
self.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd5cc>}
nname: 0
n 0(None)[self._current_config.name = str(kbd._text)
kbd.hide()
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dde4c>}
nname: 52
n 52(None)[text = self._current_config.name
self.kbd = KeyboardWindow(_('Enter a name for this configuration'), text=text, confirm_action=_set_name)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 0(t), 42()
	o: 

nname: 42
n 42(None)[]:
	i: 0(f)
	o: 52()

nname: 0
n 0(self._current_config.name)[def _cancel():
	log.error('User does not provide name. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_name(kbd):
	self._current_config.name = str(kbd._text)
	kbd.hide()
	self._next_key()

]:
	i: 
	o: 42(f), 52(t)

nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide name. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_name(kbd):
	self._current_config.name = str(kbd._text)
	kbd.hide()
	self._next_key()

if not self._current_config.name:
	pass
text = self._current_config.name
self.kbd = KeyboardWindow(_('Enter a name for this configuration'), text=text, confirm_action=_set_name)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd2ec>}
nname: 0
n 0(None)[self.set_items([], 'options0_list')
self.set_type(type)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddcec>}
nname: 0
n 0(None)[def _set_type(type):
	self.set_items([], 'options0_list')
	self.set_type(type)

it = ConnectionTypeContainer(callback=_set_type, name=_('Choose your connection type'), type_='parameters', menu=self)
self.list_options(it, 'options0_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd78c>}
nname: 0
n 0(None)[self.set_items([], 'options0_list')
self._current_config['ipConfigType'] = mode
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd70c>}
nname: 0
n 0(None)[def _set_mode(mode):
	self.set_items([], 'options0_list')
	self._current_config['ipConfigType'] = mode
	self._next_key()

it = AutoManConnectionContainer(callback=_set_mode, name=_('Choose Automatic or Manual'), type_='parameters', menu=self)
self.list_options(it, 'options0_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dda4c>}
nname: 60
n 60(None)[Task(self.config_wizard.next).start(0.20000000000000001)
]:
	i: 3(), 39(), 58(AE)
	o: 

nname: 58
n 58(None)[]:
	i: 29(f)
	o: 60(AE)

nname: 39
n 39(None)[#, e
PRINT_EXCEPTION(e)
]:
	i: 29(t)
	o: 60()

nname: 29
n 29(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 39(t), 58(f)

nname: 3
n 3(None)[self.wn.autofill(self._current_config, 'interface')
]:
	i: 0(try)
	o: 60()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 29(except)

nname: 29
n 29(None)[except Exception, e:
	PRINT_EXCEPTION(e)
Task(self.config_wizard.next).start(0.20000000000000001)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	self.wn.autofill(self._current_config, 'interface')
]:
	i: 
	o: 29()

nname: 0
n 0(None)[try:
	self.wn.autofill(self._current_config, 'interface')
except Exception, e:
	PRINT_EXCEPTION(e)
Task(self.config_wizard.next).start(0.20000000000000001)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd88c>}
nname: 0
n 0(None)[log.error('User does not provide key. Cancel configuration !')
self.kbd.hide()
self.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f0e2c>}
nname: 0
n 0(None)[self._current_config['key'] = str(kbd._text)
kbd.hide()
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f09cc>}
nname: 151
n 151(None)[self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 127(), 144()
	o: 

nname: 144
n 144(None)[text = ''
]:
	i: 102&111(f)
	o: 151()

nname: 127
n 127(None)[text = self._previous_config['key']
]:
	i: 102&111(t)
	o: 151()

nname: 102&111
n 102&111(self._previous_config and 'key' in self._previous_config)[]:
	i: 33(), 69(), 100(AE)
	o: 127(t), 144(f)

nname: 100
n 100(None)[]:
	i: 59(f)
	o: 102&111(AE)

nname: 69
n 69(None)[#, e
title = _('key')
PRINT_EXCEPTION(e)
]:
	i: 59(t)
	o: 102&111()

nname: 59
n 59(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 0(except)
	o: 69(t), 100(f)

nname: 33
n 33(None)[title = _('%(authType)s key for %(essid)s') % self._current_config.config
]:
	i: 0(try)
	o: 102&111()

nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide key. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_key(kbd):
	self._current_config['key'] = str(kbd._text)
	kbd.hide()
	self._next_key()

]:
	i: 
	o: 33(try), 59(except)

nname: 151
n 151(None)[self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 59()
	o: 

nname: 59
n 59(None)[except Exception, e:
	title = _('key')
	PRINT_EXCEPTION(e)
if self._previous_config and 'key' in self._previous_config:
	text = self._previous_config['key']
else:
	text = ''
]:
	i: 0()
	o: 151()

nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide key. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_key(kbd):
	self._current_config['key'] = str(kbd._text)
	kbd.hide()
	self._next_key()

try:
	title = _('%(authType)s key for %(essid)s') % self._current_config.config
]:
	i: 
	o: 59()

nname: 151
n 151(None)[self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide key. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_key(kbd):
	self._current_config['key'] = str(kbd._text)
	kbd.hide()
	self._next_key()

try:
	title = _('%(authType)s key for %(essid)s') % self._current_config.config
except Exception, e:
	title = _('key')
	PRINT_EXCEPTION(e)
if self._previous_config and 'key' in self._previous_config:
	text = self._previous_config['key']
else:
	text = ''
]:
	i: 
	o: 151()

nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide key. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_key(kbd):
	self._current_config['key'] = str(kbd._text)
	kbd.hide()
	self._next_key()

try:
	title = _('%(authType)s key for %(essid)s') % self._current_config.config
except Exception, e:
	title = _('key')
	PRINT_EXCEPTION(e)
if self._previous_config and 'key' in self._previous_config:
	text = self._previous_config['key']
else:
	text = ''
self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddb6c>}
nname: 0
n 0(None)[log.error('User does not provide essid. Cancel configuration !')
self.kbd.hide()
self.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd60c>}
nname: 0
n 0(None)[self._current_config['essid'] = str(kbd._text)
kbd.hide()
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddd0c>}
nname: 0
n 0(None)[def _cancel():
	log.error('User does not provide essid. Cancel configuration !')
	self.kbd.hide()
	self.hide()

def _set_essid(kbd):
	self._current_config['essid'] = str(kbd._text)
	kbd.hide()
	self._next_key()

self.kbd = KeyboardWindow('Network Name', text='', confirm_action=_set_essid)
self.kbd.action_buttons[4].connect(_cancel)
self.kbd.show()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddaac>}
nname: 0
n 0(None)[self.set_items([], 'options3_list')
self._current_config['authType'] = infos['raw_auth']
self._current_config['keyMgmt'] = infos['raw_key_mgt']
self._current_config['cipher'] = infos['raw_cipher']
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76ddfac>}
nname: 0
n 0(None)[def _set_key_type(infos):
	self.set_items([], 'options3_list')
	self._current_config['authType'] = infos['raw_auth']
	self._current_config['keyMgmt'] = infos['raw_key_mgt']
	self._current_config['cipher'] = infos['raw_cipher']
	self._next_key()

it = AuthTypeConnectionContainer(callback=_set_key_type, name=_('Choose key type'), type_='parameters', menu=self)
self.list_options(it, 'options3_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd9ec>}
nname: 58
n 58(None)[self._next_key()
]:
	i: 0(AL), 57()
	o: 

nname: 57
n 57(None)[]:
	i: 19(AF), 32()
	o: 58()

nname: 32
n 32(None)[for k, v in params.iteritems():
self._current_config[k] = v
]:
	i: 19(for)
	o: 57()

nname: 19
n 19(None)[]:
	i: 0(loop)
	o: 32(for), 57(AF)

nname: 0
n 0(None)[self.set_items([], 'options1_list')
]:
	i: 
	o: 19(loop), 58(AL)

nname: 58
n 58(None)[self._next_key()
]:
	i: 32()
	o: 

nname: 32
n 32(None)[for k, v in params.iteritems():
	self._current_config[k] = v
]:
	i: 0(for)
	o: 58()

nname: 0
n 0(None)[self.set_items([], 'options1_list')
]:
	i: 
	o: 32(for)

nname: 58
n 58(None)[self._next_key()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.set_items([], 'options1_list')
for k, v in params.iteritems():
	self._current_config[k] = v
]:
	i: 
	o: 58()

nname: 0
n 0(None)[self.set_items([], 'options1_list')
for k, v in params.iteritems():
	self._current_config[k] = v
self._next_key()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f050c>}
nname: 123
n 123(None)[it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
self.list_options(it, 'options1_list')
]:
	i: 64(AL), 118(), 122()
	o: 

nname: 122
n 122(None)[]:
	i: 0(f)
	o: 123()

nname: 118
n 118(None)[]:
	i: 68(AF), 114()
	o: 123()

nname: 114
n 114(None)[]:
	i: 75(f), 93()
	o: 118()

nname: 93
n 93(None)[default_values[k] = self._previous_config[k]
continue
]:
	i: 75(t)
	o: 114()

nname: 75
n 75(k in self._previous_config)[for k in keys:
]:
	i: 68(for)
	o: 93(t), 114(f)

nname: 68
n 68(None)[]:
	i: 64(loop)
	o: 75(for), 118(AF)

nname: 64
n 64(None)[]:
	i: 0(t)
	o: 68(loop), 123(AL)

nname: 0
n 0(self._previous_config)[def _set_ip_params(params):
	self.set_items([], 'options1_list')
	for k, v in params.iteritems():
		self._current_config[k] = v
	self._next_key()

keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
values = ['0.0.0.0'] * 5
default_values = dict(zip(keys, values))
]:
	i: 
	o: 64(t), 122(f)

nname: 123
n 123(None)[it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
self.list_options(it, 'options1_list')
]:
	i: 64(AL), 68(AF), 75(), 0(f)
	o: 

nname: 75
n 75(None)[for k in keys:
if k in self._previous_config:
	default_values[k] = self._previous_config[k]
	continue
]:
	i: 68(for)
	o: 123()

nname: 68
n 68(None)[]:
	i: 64(loop)
	o: 75(for), 123(AF)

nname: 64
n 64(None)[]:
	i: 0(t)
	o: 68(loop), 123(AL)

nname: 0
n 0(self._previous_config)[def _set_ip_params(params):
	self.set_items([], 'options1_list')
	for k, v in params.iteritems():
		self._current_config[k] = v
	self._next_key()

keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
values = ['0.0.0.0'] * 5
default_values = dict(zip(keys, values))
]:
	i: 
	o: 64(t), 123(f)

nname: 123
n 123(None)[it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
self.list_options(it, 'options1_list')
]:
	i: 75(), 0(f)
	o: 

nname: 75
n 75(None)[for k in keys:
	if k in self._previous_config:
		default_values[k] = self._previous_config[k]
		continue
]:
	i: 64(for)
	o: 123()

nname: 64
n 64(None)[]:
	i: 0(t)
	o: 75(for)

nname: 0
n 0(self._previous_config)[def _set_ip_params(params):
	self.set_items([], 'options1_list')
	for k, v in params.iteritems():
		self._current_config[k] = v
	self._next_key()

keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
values = ['0.0.0.0'] * 5
default_values = dict(zip(keys, values))
]:
	i: 
	o: 64(t), 123(f)

nname: 123
n 123(None)[it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
self.list_options(it, 'options1_list')
]:
	i: 64(), 0(f)
	o: 

nname: 64
n 64(None)[for k in keys:
	if k in self._previous_config:
		default_values[k] = self._previous_config[k]
		continue
]:
	i: 0(t)
	o: 123()

nname: 0
n 0(self._previous_config)[def _set_ip_params(params):
	self.set_items([], 'options1_list')
	for k, v in params.iteritems():
		self._current_config[k] = v
	self._next_key()

keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
values = ['0.0.0.0'] * 5
default_values = dict(zip(keys, values))
]:
	i: 
	o: 64(t), 123(f)

nname: 0
n 0(None)[def _set_ip_params(params):
	self.set_items([], 'options1_list')
	for k, v in params.iteritems():
		self._current_config[k] = v
	self._next_key()

keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
values = ['0.0.0.0'] * 5
default_values = dict(zip(keys, values))
if self._previous_config:
	for k in keys:
		if k in self._previous_config:
			default_values[k] = self._previous_config[k]
			continue
it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
self.list_options(it, 'options1_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dde8c>}
nname: 6
n 6(None)[__doc__ = ' Used to fill a new config, or edit an existing one (not yet implemented) '
def __init__(self, callback, config=None):
	self.eventhandler = WifiSelectMenuEventHandler(self)
	Menu.__init__(self, name='NetworkWizardMenu', type='network_connect', universe='setup')
	self.wn = WyNetwork()
	self._callback = callback
	self.wifi_menu = None
	self.eventhandler = WifiSelectMenuEventHandler(self)
	self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
	def self._getitems_keywords['options0_list']():
		return self.get_item_list('options0_list')

	def self._getitems_keywords['options1_list']():
		return self.get_item_list('options1_list')

	def self._getitems_keywords['options2_list']():
		return self.get_item_list('options2_list')

	def self._getitems_keywords['options3_list']():
		return self.get_item_list('options3_list')

	self.set_items([], 'options0_list')
	self.set_items([], 'options1_list')
	self.set_items([], 'options2_list')
	self.set_items([], 'options3_list')
	self.active_list = 'options0_list'
	self.config_updaters = {'networkType': self._ask_type, 'ipConfigType': self._ask_mode, 'key': self._ask_key, 'essid': self._ask_essid, 'interface': self._ask_interface, 'authType': self._ask_key_type, 'cipher': self._ask_key_type, 'keyMgmt': self._ask_key_type, 'ipAddress': self._ask_ip_params, 'netmask': self._ask_ip_params, 'gateway': self._ask_ip_params}
	self._previous_config = None
	self._current_config = self.wn.new_config()
	log.debug('create new config')
	if config and isinstance(config, WyNetworkConfig):
		if config.is_valid():
			log.debug('editing %s (not implemented)', config.name)
			self._previous_config = config
		else:
			log.error('previous_config %s is not valid. Cancel configuration', config)
			return None
	if '802.11' not in self.wn.availables_networkType():
		log.debug('no 802.11 devices, set_ethernet()')
		self._current_config.set_ethernet()
		if self._previous_config and self._previous_config['networkType'] == '802.11':
			log.error('Editing 802.11 config but no wireless device found. Cancel configuration')
			return None
	log.debug('current_config %s', self._current_config)
	return None

def show(self, hide_previous_menu=True):
	Menu.show(self, hide_previous_menu)
	self.start()

def start(self):
	self.config_wizard = self.configurator()
	self.config_wizard.next()
	if self._previous_config:
		self.set_type(self._previous_config['networkType'])
	else:
		self.config_wizard.next()

def execute_selected(self):
	self[self.active_list].selected.execute()

def list_options(self, item, browse_list_name='options0_list'):
	self.set_items([item], 'main_list')
	for l in self.available_choices:
		self.set_items([], l)
	self.set_items(item.browse(), browse_list_name)
	self.active_list = browse_list_name

def _wifi_callback(self, network):
	log.debug('selected network: %s', network)
	self._current_config.set_network(network)
	log.debug('config: %s', self._current_config)
	self.wifi_menu.hide()
	try:
		self.config_wizard.next()
	except StopIteration:
		log.debug('config_wizard STOP')

def configurator(self):
	log.debug('init')
	cur_conf_configurator = self._current_config.configurator()
	cur_conf_configurator.next()
	yield None
	log.debug('start !')

def _next_key(self):
	try:
		self.config_wizard.next()
	except StopIteration:
		log.debug('fill_config STOP')

def _save_config(self):
	log.debug('Configuration done. saving...')
	try:
		self.wn.save_config(self._current_config)
	except Exception, e:
		PRINT_EXCEPTION(e)
	self._callback(self._current_config)

def set_type(self, type):
	self._current_config['networkType'] = type
	if type == '802.3':
		self._current_config.set_ethernet()
		self._next_key()
	else:
		if type == '802.11':
			self.wifi_menu = WifiSelectMenu(callback=self._wifi_callback)
			self.wifi_menu.show()

def _ask_name(self):
	def _cancel():
		log.error('User does not provide name. Cancel configuration !')
		self.kbd.hide()
		self.hide()

	def _set_name(kbd):
		self._current_config.name = str(kbd._text)
		kbd.hide()
		self._next_key()

	if not self._current_config.name:
		pass
	text = self._current_config.name
	self.kbd = KeyboardWindow(_('Enter a name for this configuration'), text=text, confirm_action=_set_name)
	self.kbd.action_buttons[4].connect(_cancel)
	self.kbd.show()

def _ask_type(self):
	def _set_type(type):
		self.set_items([], 'options0_list')
		self.set_type(type)

	it = ConnectionTypeContainer(callback=_set_type, name=_('Choose your connection type'), type_='parameters', menu=self)
	self.list_options(it, 'options0_list')

def _ask_mode(self):
	def _set_mode(mode):
		self.set_items([], 'options0_list')
		self._current_config['ipConfigType'] = mode
		self._next_key()

	it = AutoManConnectionContainer(callback=_set_mode, name=_('Choose Automatic or Manual'), type_='parameters', menu=self)
	self.list_options(it, 'options0_list')

def _ask_interface(self):
	try:
		self.wn.autofill(self._current_config, 'interface')
	except Exception, e:
		PRINT_EXCEPTION(e)
	Task(self.config_wizard.next).start(0.20000000000000001)

def _ask_key(self):
	def _cancel():
		log.error('User does not provide key. Cancel configuration !')
		self.kbd.hide()
		self.hide()

	def _set_key(kbd):
		self._current_config['key'] = str(kbd._text)
		kbd.hide()
		self._next_key()

	try:
		title = _('%(authType)s key for %(essid)s') % self._current_config.config
	except Exception, e:
		title = _('key')
		PRINT_EXCEPTION(e)
	if self._previous_config and 'key' in self._previous_config:
		text = self._previous_config['key']
	else:
		text = ''
	self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
	self.kbd.action_buttons[4].connect(_cancel)
	self.kbd.show()

def _ask_essid(self):
	def _cancel():
		log.error('User does not provide essid. Cancel configuration !')
		self.kbd.hide()
		self.hide()

	def _set_essid(kbd):
		self._current_config['essid'] = str(kbd._text)
		kbd.hide()
		self._next_key()

	self.kbd = KeyboardWindow('Network Name', text='', confirm_action=_set_essid)
	self.kbd.action_buttons[4].connect(_cancel)
	self.kbd.show()

def _ask_key_type(self):
	def _set_key_type(infos):
		self.set_items([], 'options3_list')
		self._current_config['authType'] = infos['raw_auth']
		self._current_config['keyMgmt'] = infos['raw_key_mgt']
		self._current_config['cipher'] = infos['raw_cipher']
		self._next_key()

	it = AuthTypeConnectionContainer(callback=_set_key_type, name=_('Choose key type'), type_='parameters', menu=self)
	self.list_options(it, 'options3_list')

def _ask_ip_params(self):
	def _set_ip_params(params):
		self.set_items([], 'options1_list')
		for k, v in params.iteritems():
			self._current_config[k] = v
		self._next_key()

	keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
	values = ['0.0.0.0'] * 5
	default_values = dict(zip(keys, values))
	if self._previous_config:
		for k in keys:
			if k in self._previous_config:
				default_values[k] = self._previous_config[k]
				continue
	it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
	self.list_options(it, 'options1_list')

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76da7ac>}
nname: 0
n 0(None)[return self.get_item_list('crypto_list')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd16c>}
nname: 0
n 0(None)[self.eventhandler = WifiSelectMenuEventHandler(self)
Menu.__init__(self, name, type='wifi_select', universe='setup')
self.available_choices = ['main_list', 'crypto_list']
def self._getitems_keywords['crypto_list']():
	return self.get_item_list('crypto_list')

self.set_items([], 'main_list')
self.set_items([], 'crypto_list')
self._callback = callback
self.can_scan = True
self.on_network_appeared_task = Task(self._on_network_appeared)
self.on_network_disappeared_task = Task(self._on_network_disappeared)
self.wn = WyNetwork()
self.wn.wn_net.attach(self)
self.list_networks()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dd7ac>}
nname: 86
n 86(None)[]:
	i: 59(), 85()
	o: 

nname: 85
n 85(None)[]:
	i: 0(f), 50(f)
	o: 86()

nname: 59
n 59(None)[Menu.select(self, item, 'crypto_list', force_pos)
]:
	i: 50(t)
	o: 86()

nname: 50
n 50(list_name == 'main_list')[]:
	i: 36(t), 43()
	o: 59(t), 85(f)

nname: 43
n 43(None)[]:
	i: 36(f)
	o: 50()

nname: 36
n 36(list_name)[]:
	i: 0(t)
	o: 43(f), 50(t)

nname: 0
n 0(ret is not False)[ret = Menu.select(self, item, list_name, force_pos)
]:
	i: 
	o: 36(t), 50(f)

nname: 86
n 86(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[ret = Menu.select(self, item, list_name, force_pos)
if ret is not False:
	if not list_name:
		pass
if list_name == 'main_list':
	Menu.select(self, item, 'crypto_list', force_pos)
]:
	i: 
	o: 86()

nname: 0
n 0(None)[ret = Menu.select(self, item, list_name, force_pos)
if ret is not False:
	if not list_name:
		pass
if list_name == 'main_list':
	Menu.select(self, item, 'crypto_list', force_pos)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76daaac>}
nname: 0
n 0(None)[self.selected.execute()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76daaec>}
nname: 0
n 0(None)[self.wn.wn_net.detach(self)
Menu.stop(self)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76da6cc>}
nname: 0
n 0(None)[self.list_networks()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dacac>}
nname: 0
n 0(None)[self.list_networks()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76da6cc>}
nname: 0
n 0(None)[self.on_network_appeared_task.args = (dev, net)
self.on_network_appeared_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76dab8c>}
nname: 0
n 0(None)[self.on_network_disappeared_task.args = (dev, net)
self.on_network_disappeared_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76da10c>}
nname: 350
n 350(None)[return None
]:
	i: 197(), 336()
	o: 

nname: 336
n 336(None)[log.debug('scan blocked by pending configuration process')
]:
	i: 0(f)
	o: 350()

nname: 197
n 197(None)[hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
hidden_crypto.display_type = 'not_crypted'
hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
it_list.append(hidden_it)
crypto_list.append(hidden_crypto)
self.set_items(it_list, 'main_list')
self.set_items(crypto_list, 'crypto_list')
]:
	i: 21(AL), 196()
	o: 350()

nname: 196
n 196(None)[]:
	i: 25(AF), 90()
	o: 197()

nname: 90
n 90(None)[crypto.display_type = 'not_crypted'
it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
it.display_type = self._get_display_type(network['strength'])
it_list.append(it)
crypto_list.append(crypto)
]:
	i: 79(), 86()
	o: 196()

nname: 86
n 86(None)[]:
	i: 41(f)
	o: 90()

nname: 79
n 79(None)[]:
	i: 41(t)
	o: 90()

nname: 41
n 41(network['authType'])[for network in self.wn.get_networks():
crypto = CryptoItem(network['essid'], '', type_='setupitem')
]:
	i: 25(for)
	o: 79(t), 86(f)

nname: 25
n 25(None)[]:
	i: 21(loop)
	o: 41(for), 196(AF)

nname: 21
n 21(None)[]:
	i: 0(t)
	o: 25(loop), 197(AL)

nname: 0
n 0(self.can_scan)[it_list = []
crypto_list = []
]:
	i: 
	o: 21(t), 336(f)

nname: 350
n 350(None)[return None
]:
	i: 197(), 336()
	o: 

nname: 336
n 336(None)[log.debug('scan blocked by pending configuration process')
]:
	i: 0(f)
	o: 350()

nname: 197
n 197(None)[hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
hidden_crypto.display_type = 'not_crypted'
hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
it_list.append(hidden_it)
crypto_list.append(hidden_crypto)
self.set_items(it_list, 'main_list')
self.set_items(crypto_list, 'crypto_list')
]:
	i: 21(AL), 25(AF), 41()
	o: 350()

nname: 41
n 41(None)[for network in self.wn.get_networks():
crypto = CryptoItem(network['essid'], '', type_='setupitem')
if network['authType']:
	pass
crypto.display_type = 'not_crypted'
it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
it.display_type = self._get_display_type(network['strength'])
it_list.append(it)
crypto_list.append(crypto)
]:
	i: 25(for)
	o: 197()

nname: 25
n 25(None)[]:
	i: 21(loop)
	o: 41(for), 197(AF)

nname: 21
n 21(None)[]:
	i: 0(t)
	o: 25(loop), 197(AL)

nname: 0
n 0(self.can_scan)[it_list = []
crypto_list = []
]:
	i: 
	o: 21(t), 336(f)

nname: 350
n 350(None)[return None
]:
	i: 41(), 336()
	o: 

nname: 336
n 336(None)[log.debug('scan blocked by pending configuration process')
]:
	i: 0(f)
	o: 350()

nname: 41
n 41(None)[for network in self.wn.get_networks():
	crypto = CryptoItem(network['essid'], '', type_='setupitem')
	if network['authType']:
		pass
	crypto.display_type = 'not_crypted'
	it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
	it.display_type = self._get_display_type(network['strength'])
	it_list.append(it)
	crypto_list.append(crypto)
hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
hidden_crypto.display_type = 'not_crypted'
hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
it_list.append(hidden_it)
crypto_list.append(hidden_crypto)
self.set_items(it_list, 'main_list')
self.set_items(crypto_list, 'crypto_list')
]:
	i: 21(for)
	o: 350()

nname: 21
n 21(None)[]:
	i: 0(t)
	o: 41(for)

nname: 0
n 0(self.can_scan)[it_list = []
crypto_list = []
]:
	i: 
	o: 21(t), 336(f)

nname: 350
n 350(None)[return None
]:
	i: 21(), 336()
	o: 

nname: 336
n 336(None)[log.debug('scan blocked by pending configuration process')
]:
	i: 0(f)
	o: 350()

nname: 21
n 21(None)[for network in self.wn.get_networks():
	crypto = CryptoItem(network['essid'], '', type_='setupitem')
	if network['authType']:
		pass
	crypto.display_type = 'not_crypted'
	it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
	it.display_type = self._get_display_type(network['strength'])
	it_list.append(it)
	crypto_list.append(crypto)
hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
hidden_crypto.display_type = 'not_crypted'
hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
it_list.append(hidden_it)
crypto_list.append(hidden_crypto)
self.set_items(it_list, 'main_list')
self.set_items(crypto_list, 'crypto_list')
]:
	i: 0(t)
	o: 350()

nname: 0
n 0(self.can_scan)[it_list = []
crypto_list = []
]:
	i: 
	o: 21(t), 336(f)

nname: 0
n 0(None)[it_list = []
crypto_list = []
if self.can_scan:
	for network in self.wn.get_networks():
		crypto = CryptoItem(network['essid'], '', type_='setupitem')
		if network['authType']:
			pass
		crypto.display_type = 'not_crypted'
		it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
		it.display_type = self._get_display_type(network['strength'])
		it_list.append(it)
		crypto_list.append(crypto)
	hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
	hidden_crypto.display_type = 'not_crypted'
	hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
	it_list.append(hidden_it)
	crypto_list.append(hidden_crypto)
	self.set_items(it_list, 'main_list')
	self.set_items(crypto_list, 'crypto_list')
else:
	log.debug('scan blocked by pending configuration process')
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f03ec>}
nname: 126
n 126(None)[return 'wifi_signal_5'
]:
	i: 50(JA), 71(JA), 92(JA), 113(JA), 121(), 125()
	o: 

nname: 125
n 125(None)[]:
	i: 0&24(f)
	o: 126()

nname: 121
n 121(None)[]:
	i: 100(f)
	o: 126()

nname: 113
n 113(None)[return 'wifi_signal_4'
]:
	i: 100(t)
	o: 126(JA)

nname: 100
n 100(strength > 20)[]:
	i: 79(f)
	o: 113(t), 121(f)

nname: 92
n 92(None)[return 'wifi_signal_3'
]:
	i: 79(t)
	o: 126(JA)

nname: 79
n 79(strength > 40)[]:
	i: 58(f)
	o: 92(t), 100(f)

nname: 71
n 71(None)[return 'wifi_signal_2'
]:
	i: 58(t)
	o: 126(JA)

nname: 58
n 58(strength > 60)[]:
	i: 37(f)
	o: 71(t), 79(f)

nname: 50
n 50(None)[return 'wifi_signal_1'
]:
	i: 37(t)
	o: 126(JA)

nname: 37
n 37(strength > 80)[]:
	i: 0&24(t)
	o: 50(t), 58(f)

nname: 0&24
n 0&24(strength > 0 and strength <= 100)[strength = int(strength)
]:
	i: 
	o: 37(t), 125(f)

nname: 0&24
n 0&24(None)[strength = int(strength)
if strength > 0 and strength <= 100:
	if strength > 80:
		return 'wifi_signal_1'
	else:
		if strength > 60:
			return 'wifi_signal_2'
		else:
			if strength > 40:
				return 'wifi_signal_3'
			else:
				if strength > 20:
					return 'wifi_signal_4'
return 'wifi_signal_5'
]:
	i: 
	o: 

self.nodes: {'0&24': <unpyclib.structure.node instance at 0xb76da7cc>}
nname: 6
n 6(None)[__doc__ = ' Juste list availables wifi network '
def __init__(self, callback, name='Network Connect menu'):
	self.eventhandler = WifiSelectMenuEventHandler(self)
	Menu.__init__(self, name, type='wifi_select', universe='setup')
	self.available_choices = ['main_list', 'crypto_list']
	def self._getitems_keywords['crypto_list']():
		return self.get_item_list('crypto_list')

	self.set_items([], 'main_list')
	self.set_items([], 'crypto_list')
	self._callback = callback
	self.can_scan = True
	self.on_network_appeared_task = Task(self._on_network_appeared)
	self.on_network_disappeared_task = Task(self._on_network_disappeared)
	self.wn = WyNetwork()
	self.wn.wn_net.attach(self)
	self.list_networks()

def select(self, item, list_name=None, force_pos=False):
	ret = Menu.select(self, item, list_name, force_pos)
	if ret is not False:
		if not list_name:
			pass
	if list_name == 'main_list':
		Menu.select(self, item, 'crypto_list', force_pos)

def execute_selected(self):
	self.selected.execute()

def stop(self):
	self.wn.wn_net.detach(self)
	Menu.stop(self)

def _on_network_appeared(self, dev, net):
	self.list_networks()

def _on_network_disappeared(self, dev, net):
	self.list_networks()

def onNetworkAppeared(self, dev, net):
	self.on_network_appeared_task.args = (dev, net)
	self.on_network_appeared_task.start(1)

def onNetworkDisappeared(self, dev, net):
	self.on_network_disappeared_task.args = (dev, net)
	self.on_network_disappeared_task.start(1)

def list_networks(self):
	it_list = []
	crypto_list = []
	if self.can_scan:
		for network in self.wn.get_networks():
			crypto = CryptoItem(network['essid'], '', type_='setupitem')
			if network['authType']:
				pass
			crypto.display_type = 'not_crypted'
			it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
			it.display_type = self._get_display_type(network['strength'])
			it_list.append(it)
			crypto_list.append(crypto)
		hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
		hidden_crypto.display_type = 'not_crypted'
		hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
		it_list.append(hidden_it)
		crypto_list.append(hidden_crypto)
		self.set_items(it_list, 'main_list')
		self.set_items(crypto_list, 'crypto_list')
	else:
		log.debug('scan blocked by pending configuration process')
	return None

def _get_display_type(self, strength):
	strength = int(strength)
	if strength > 0 and strength <= 100:
		if strength > 80:
			return 'wifi_signal_1'
		else:
			if strength > 60:
				return 'wifi_signal_2'
			else:
				if strength > 40:
					return 'wifi_signal_3'
				else:
					if strength > 20:
						return 'wifi_signal_4'
	return 'wifi_signal_5'

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76dbd6c>}
nname: 0
n 0(None)[from __future__ import absolute_import
from peewee.messages import send as louie_send
from peewee.notifier import Task
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from wynetwork.utils import WyNetwork, WyNetworkConfig
from pygui.item.core import ActionItem, Item
from pygui.item.parameters.network.networksetup import ConnectionTypeContainer, AutoManConnectionContainer, AuthTypeConnectionContainer, EditNetworkConfSetupItem
from pygui.menu.menu import Menu
from pygui.eventmanager.menus import WifiSelectMenuEventHandler
from pygui.window import KeyboardWindow, BigConfirmWindow, ConfirmWindow, Button, MessageWindow, LoadingWindow
from pygui.config import user_config, plugins
log = GET_LOGGER(__name__)
class CryptoItem(Item):
	def __init__(self, network, *args, **args):
		Item.__init__(self, *args, **kw)
		self.network = network

	def __eq__(self, other):
		if isinstance(other, CryptoItem):
			return self.network == other.network
		return False

	def __cmp__(self, other):
		if isinstance(other, CryptoItem):
			return cmp(self.network, other.network)
		else:
			return cmp(type(self), type(other))



class NetworkConnectMenu(Menu):
	__doc__ = ' To manage configurations (select, active or delete a config) '
	def __init__(self, **kw):
		self.on_device_connected_task = Task(self._on_device_connected)
		self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
		self.wn = WyNetwork()
		self.wn.wn_dev.attach(self)
		try:
			self.wn.set_scanning(True)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self._connecting_config = None
		Menu.__init__(self, choices=[], **kw)
		self.wizard_menu = None
		self.connect_win = None
		self.loading_win = None
		self.eventhandler = WifiSelectMenuEventHandler(self)
		self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
		def self._getitems_keywords['options0_list']():
			return self.get_item_list('options0_list')

		def self._getitems_keywords['options1_list']():
			return self.get_item_list('options1_list')

		def self._getitems_keywords['options2_list']():
			return self.get_item_list('options2_list')

		def self._getitems_keywords['options3_list']():
			return self.get_item_list('options3_list')

		self.set_items([], 'options0_list')
		self.set_items([], 'options1_list')
		self.set_items([], 'options2_list')
		self.set_items([], 'options3_list')
		self.active_list = 'options2_list'
		self.list_configs()
		return None

	def execute_selected(self):
		self[self.active_list].selected.execute()

	def stop(self):
		log.debug('Detach from wynetwork signals and set_scanning(False)')
		try:
			self.wn.set_scanning(False)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self.wn.wn_dev.detach(self)
		Menu.stop(self)

	def list_configs(self):
		cfg_list = []
		self._connecting_config = None
		for config in self.wn.get_configs():
			log.debug('config %s', config.name)
			cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
		cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
		self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
		self.set_items(cfg_list, 'options2_list')
		self.active_list = 'options2_list'
		return None

	def select_config(self, config):
		log.debug(config)
		buttons = []
		if config.is_valid():
			buttons.append(Button(_('Connect'), True))
			buttons[-1].connect(self.active_config, config)
		if config.is_removable():
			buttons.append(Button(_('Edit'), False))
			buttons[-1].connect(self.edit_config, config)
			buttons.append(Button(_('Delete'), False))
			buttons[-1].connect(self.delete_config, config)
		if buttons:
			cw = BigConfirmWindow(config.name, buttons)
			cw.show()

	def active_config(self, config):
		self.loading_win = LoadingWindow()
		self.loading_win.show()
		log.debug(config)
		self._connecting_config = config
		title = _('Connecting to %(net)s') % dict(net=config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=180)
		try:
			self.wn.active_config(config)
		except Exception, e:
			PRINT_EXCEPTION(e)
		return None

	def edit_config(self, config):
		log.debug(config)
		louie_send('on_%s_blur' % self._active_list, self)
		self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=config)
		self.wizard_menu.show()

	def delete_config(self, config):
		log.debug(config)
		def _do_delete():
			try:
				self.wn.delete_config(config)
			except Exception, e:
				PRINT_EXCEPTION(e)
			finally:
				self.list_configs()

		cw = ConfirmWindow(_('Are you sure ?'), confirm_action=_do_delete)
		cw.show()

	def create_config(self):
		louie_send('on_%s_blur' % self._active_list, self)
		self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=None)
		self.wizard_menu.show()
		return None

	def _on_device_connected(self, device):
		if self.loading_win is not None:
			self.loading_win.hide()
		log.debug(self._connecting_config)
		self.connect_win.hide()
		title = _('Connected to %(net)s') % dict(net=self._connecting_config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=3)
		self.hide()
		return None

	def _wizard_callback(self, config):
		log.debug('config = %s', config)
		if config == None:
			MessageWindow(_('Error during configuration'), button=None).show(5)
		self.wizard_menu.hide()
		self.list_configs()
		return None

	def _on_device_connection_failed(self, device):
		log.debug(self._connecting_config)
		self.connect_win.hide()
		title = _('Disconnected from %(net)s') % dict(net=self._connecting_config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=3)
		self.list_configs()
		return None

	def onDeviceConnected(self, device):
		log.debug(device)
		self.on_device_connected_task.args = (device,)
		self.on_device_connected_task.start(1)

	def onDeviceConnectionFailed(self, device):
		log.debug(device)
		self.on_device_connection_failed_task.args = (device,)
		self.on_device_connection_failed_task.start(1)

	def onDeviceConnecting(self, device):
		pass

	def onDeviceDisconnected(self, device):
		pass



class NetworkWizardMenu(Menu):
	__doc__ = ' Used to fill a new config, or edit an existing one (not yet implemented) '
	def __init__(self, callback, config=None):
		self.eventhandler = WifiSelectMenuEventHandler(self)
		Menu.__init__(self, name='NetworkWizardMenu', type='network_connect', universe='setup')
		self.wn = WyNetwork()
		self._callback = callback
		self.wifi_menu = None
		self.eventhandler = WifiSelectMenuEventHandler(self)
		self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
		def self._getitems_keywords['options0_list']():
			return self.get_item_list('options0_list')

		def self._getitems_keywords['options1_list']():
			return self.get_item_list('options1_list')

		def self._getitems_keywords['options2_list']():
			return self.get_item_list('options2_list')

		def self._getitems_keywords['options3_list']():
			return self.get_item_list('options3_list')

		self.set_items([], 'options0_list')
		self.set_items([], 'options1_list')
		self.set_items([], 'options2_list')
		self.set_items([], 'options3_list')
		self.active_list = 'options0_list'
		self.config_updaters = {'networkType': self._ask_type, 'ipConfigType': self._ask_mode, 'key': self._ask_key, 'essid': self._ask_essid, 'interface': self._ask_interface, 'authType': self._ask_key_type, 'cipher': self._ask_key_type, 'keyMgmt': self._ask_key_type, 'ipAddress': self._ask_ip_params, 'netmask': self._ask_ip_params, 'gateway': self._ask_ip_params}
		self._previous_config = None
		self._current_config = self.wn.new_config()
		log.debug('create new config')
		if config and isinstance(config, WyNetworkConfig):
			if config.is_valid():
				log.debug('editing %s (not implemented)', config.name)
				self._previous_config = config
			else:
				log.error('previous_config %s is not valid. Cancel configuration', config)
				return None
		if '802.11' not in self.wn.availables_networkType():
			log.debug('no 802.11 devices, set_ethernet()')
			self._current_config.set_ethernet()
			if self._previous_config and self._previous_config['networkType'] == '802.11':
				log.error('Editing 802.11 config but no wireless device found. Cancel configuration')
				return None
		log.debug('current_config %s', self._current_config)
		return None

	def show(self, hide_previous_menu=True):
		Menu.show(self, hide_previous_menu)
		self.start()

	def start(self):
		self.config_wizard = self.configurator()
		self.config_wizard.next()
		if self._previous_config:
			self.set_type(self._previous_config['networkType'])
		else:
			self.config_wizard.next()

	def execute_selected(self):
		self[self.active_list].selected.execute()

	def list_options(self, item, browse_list_name='options0_list'):
		self.set_items([item], 'main_list')
		for l in self.available_choices:
			self.set_items([], l)
		self.set_items(item.browse(), browse_list_name)
		self.active_list = browse_list_name

	def _wifi_callback(self, network):
		log.debug('selected network: %s', network)
		self._current_config.set_network(network)
		log.debug('config: %s', self._current_config)
		self.wifi_menu.hide()
		try:
			self.config_wizard.next()
		except StopIteration:
			log.debug('config_wizard STOP')

	def configurator(self):
		log.debug('init')
		cur_conf_configurator = self._current_config.configurator()
		cur_conf_configurator.next()
		yield None
		log.debug('start !')

	def _next_key(self):
		try:
			self.config_wizard.next()
		except StopIteration:
			log.debug('fill_config STOP')

	def _save_config(self):
		log.debug('Configuration done. saving...')
		try:
			self.wn.save_config(self._current_config)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self._callback(self._current_config)

	def set_type(self, type):
		self._current_config['networkType'] = type
		if type == '802.3':
			self._current_config.set_ethernet()
			self._next_key()
		else:
			if type == '802.11':
				self.wifi_menu = WifiSelectMenu(callback=self._wifi_callback)
				self.wifi_menu.show()

	def _ask_name(self):
		def _cancel():
			log.error('User does not provide name. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_name(kbd):
			self._current_config.name = str(kbd._text)
			kbd.hide()
			self._next_key()

		if not self._current_config.name:
			pass
		text = self._current_config.name
		self.kbd = KeyboardWindow(_('Enter a name for this configuration'), text=text, confirm_action=_set_name)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_type(self):
		def _set_type(type):
			self.set_items([], 'options0_list')
			self.set_type(type)

		it = ConnectionTypeContainer(callback=_set_type, name=_('Choose your connection type'), type_='parameters', menu=self)
		self.list_options(it, 'options0_list')

	def _ask_mode(self):
		def _set_mode(mode):
			self.set_items([], 'options0_list')
			self._current_config['ipConfigType'] = mode
			self._next_key()

		it = AutoManConnectionContainer(callback=_set_mode, name=_('Choose Automatic or Manual'), type_='parameters', menu=self)
		self.list_options(it, 'options0_list')

	def _ask_interface(self):
		try:
			self.wn.autofill(self._current_config, 'interface')
		except Exception, e:
			PRINT_EXCEPTION(e)
		Task(self.config_wizard.next).start(0.20000000000000001)

	def _ask_key(self):
		def _cancel():
			log.error('User does not provide key. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_key(kbd):
			self._current_config['key'] = str(kbd._text)
			kbd.hide()
			self._next_key()

		try:
			title = _('%(authType)s key for %(essid)s') % self._current_config.config
		except Exception, e:
			title = _('key')
			PRINT_EXCEPTION(e)
		if self._previous_config and 'key' in self._previous_config:
			text = self._previous_config['key']
		else:
			text = ''
		self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_essid(self):
		def _cancel():
			log.error('User does not provide essid. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_essid(kbd):
			self._current_config['essid'] = str(kbd._text)
			kbd.hide()
			self._next_key()

		self.kbd = KeyboardWindow('Network Name', text='', confirm_action=_set_essid)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_key_type(self):
		def _set_key_type(infos):
			self.set_items([], 'options3_list')
			self._current_config['authType'] = infos['raw_auth']
			self._current_config['keyMgmt'] = infos['raw_key_mgt']
			self._current_config['cipher'] = infos['raw_cipher']
			self._next_key()

		it = AuthTypeConnectionContainer(callback=_set_key_type, name=_('Choose key type'), type_='parameters', menu=self)
		self.list_options(it, 'options3_list')

	def _ask_ip_params(self):
		def _set_ip_params(params):
			self.set_items([], 'options1_list')
			for k, v in params.iteritems():
				self._current_config[k] = v
			self._next_key()

		keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
		values = ['0.0.0.0'] * 5
		default_values = dict(zip(keys, values))
		if self._previous_config:
			for k in keys:
				if k in self._previous_config:
					default_values[k] = self._previous_config[k]
					continue
		it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
		self.list_options(it, 'options1_list')



class WifiSelectMenu(Menu):
	__doc__ = ' Juste list availables wifi network '
	def __init__(self, callback, name='Network Connect menu'):
		self.eventhandler = WifiSelectMenuEventHandler(self)
		Menu.__init__(self, name, type='wifi_select', universe='setup')
		self.available_choices = ['main_list', 'crypto_list']
		def self._getitems_keywords['crypto_list']():
			return self.get_item_list('crypto_list')

		self.set_items([], 'main_list')
		self.set_items([], 'crypto_list')
		self._callback = callback
		self.can_scan = True
		self.on_network_appeared_task = Task(self._on_network_appeared)
		self.on_network_disappeared_task = Task(self._on_network_disappeared)
		self.wn = WyNetwork()
		self.wn.wn_net.attach(self)
		self.list_networks()

	def select(self, item, list_name=None, force_pos=False):
		ret = Menu.select(self, item, list_name, force_pos)
		if ret is not False:
			if not list_name:
				pass
		if list_name == 'main_list':
			Menu.select(self, item, 'crypto_list', force_pos)

	def execute_selected(self):
		self.selected.execute()

	def stop(self):
		self.wn.wn_net.detach(self)
		Menu.stop(self)

	def _on_network_appeared(self, dev, net):
		self.list_networks()

	def _on_network_disappeared(self, dev, net):
		self.list_networks()

	def onNetworkAppeared(self, dev, net):
		self.on_network_appeared_task.args = (dev, net)
		self.on_network_appeared_task.start(1)

	def onNetworkDisappeared(self, dev, net):
		self.on_network_disappeared_task.args = (dev, net)
		self.on_network_disappeared_task.start(1)

	def list_networks(self):
		it_list = []
		crypto_list = []
		if self.can_scan:
			for network in self.wn.get_networks():
				crypto = CryptoItem(network['essid'], '', type_='setupitem')
				if network['authType']:
					pass
				crypto.display_type = 'not_crypted'
				it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
				it.display_type = self._get_display_type(network['strength'])
				it_list.append(it)
				crypto_list.append(crypto)
			hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
			hidden_crypto.display_type = 'not_crypted'
			hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
			it_list.append(hidden_it)
			crypto_list.append(hidden_crypto)
			self.set_items(it_list, 'main_list')
			self.set_items(crypto_list, 'crypto_list')
		else:
			log.debug('scan blocked by pending configuration process')
		return None

	def _get_display_type(self, strength):
		strength = int(strength)
		if strength > 0 and strength <= 100:
			if strength > 80:
				return 'wifi_signal_1'
			else:
				if strength > 60:
					return 'wifi_signal_2'
				else:
					if strength > 40:
						return 'wifi_signal_3'
					else:
						if strength > 20:
							return 'wifi_signal_4'
		return 'wifi_signal_5'



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76cd32c>}
from __future__ import absolute_import
from peewee.messages import send as louie_send
from peewee.notifier import Task
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from wynetwork.utils import WyNetwork, WyNetworkConfig
from pygui.item.core import ActionItem, Item
from pygui.item.parameters.network.networksetup import ConnectionTypeContainer, AutoManConnectionContainer, AuthTypeConnectionContainer, EditNetworkConfSetupItem
from pygui.menu.menu import Menu
from pygui.eventmanager.menus import WifiSelectMenuEventHandler
from pygui.window import KeyboardWindow, BigConfirmWindow, ConfirmWindow, Button, MessageWindow, LoadingWindow
from pygui.config import user_config, plugins
log = GET_LOGGER(__name__)
class CryptoItem(Item):
	def __init__(self, network, *args, **args):
		Item.__init__(self, *args, **kw)
		self.network = network

	def __eq__(self, other):
		if isinstance(other, CryptoItem):
			return self.network == other.network
		return False

	def __cmp__(self, other):
		if isinstance(other, CryptoItem):
			return cmp(self.network, other.network)
		else:
			return cmp(type(self), type(other))



class NetworkConnectMenu(Menu):
	__doc__ = ' To manage configurations (select, active or delete a config) '
	def __init__(self, **kw):
		self.on_device_connected_task = Task(self._on_device_connected)
		self.on_device_connection_failed_task = Task(self._on_device_connection_failed)
		self.wn = WyNetwork()
		self.wn.wn_dev.attach(self)
		try:
			self.wn.set_scanning(True)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self._connecting_config = None
		Menu.__init__(self, choices=[], **kw)
		self.wizard_menu = None
		self.connect_win = None
		self.loading_win = None
		self.eventhandler = WifiSelectMenuEventHandler(self)
		self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
		def self._getitems_keywords['options0_list']():
			return self.get_item_list('options0_list')

		def self._getitems_keywords['options1_list']():
			return self.get_item_list('options1_list')

		def self._getitems_keywords['options2_list']():
			return self.get_item_list('options2_list')

		def self._getitems_keywords['options3_list']():
			return self.get_item_list('options3_list')

		self.set_items([], 'options0_list')
		self.set_items([], 'options1_list')
		self.set_items([], 'options2_list')
		self.set_items([], 'options3_list')
		self.active_list = 'options2_list'
		self.list_configs()
		return None

	def execute_selected(self):
		self[self.active_list].selected.execute()

	def stop(self):
		log.debug('Detach from wynetwork signals and set_scanning(False)')
		try:
			self.wn.set_scanning(False)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self.wn.wn_dev.detach(self)
		Menu.stop(self)

	def list_configs(self):
		cfg_list = []
		self._connecting_config = None
		for config in self.wn.get_configs():
			log.debug('config %s', config.name)
			cfg_list.append(ActionItem(config.name, type_='setupitem', action=self.select_config, args=[config]))
		cfg_list.append(ActionItem(_('Create a new configuration'), type_='setupitem', display_type='create_new_config', action=self.create_config, args=[]))
		self.set_items([Item(_('Choose your configuration'), type_='setupitem')], 'main_list')
		self.set_items(cfg_list, 'options2_list')
		self.active_list = 'options2_list'
		return None

	def select_config(self, config):
		log.debug(config)
		buttons = []
		if config.is_valid():
			buttons.append(Button(_('Connect'), True))
			buttons[-1].connect(self.active_config, config)
		if config.is_removable():
			buttons.append(Button(_('Edit'), False))
			buttons[-1].connect(self.edit_config, config)
			buttons.append(Button(_('Delete'), False))
			buttons[-1].connect(self.delete_config, config)
		if buttons:
			cw = BigConfirmWindow(config.name, buttons)
			cw.show()

	def active_config(self, config):
		self.loading_win = LoadingWindow()
		self.loading_win.show()
		log.debug(config)
		self._connecting_config = config
		title = _('Connecting to %(net)s') % dict(net=config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=180)
		try:
			self.wn.active_config(config)
		except Exception, e:
			PRINT_EXCEPTION(e)
		return None

	def edit_config(self, config):
		log.debug(config)
		louie_send('on_%s_blur' % self._active_list, self)
		self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=config)
		self.wizard_menu.show()

	def delete_config(self, config):
		log.debug(config)
		def _do_delete():
			try:
				self.wn.delete_config(config)
			except Exception, e:
				PRINT_EXCEPTION(e)
			finally:
				self.list_configs()

		cw = ConfirmWindow(_('Are you sure ?'), confirm_action=_do_delete)
		cw.show()

	def create_config(self):
		louie_send('on_%s_blur' % self._active_list, self)
		self.wizard_menu = NetworkWizardMenu(callback=self._wizard_callback, config=None)
		self.wizard_menu.show()
		return None

	def _on_device_connected(self, device):
		if self.loading_win is not None:
			self.loading_win.hide()
		log.debug(self._connecting_config)
		self.connect_win.hide()
		title = _('Connected to %(net)s') % dict(net=self._connecting_config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=3)
		self.hide()
		return None

	def _wizard_callback(self, config):
		log.debug('config = %s', config)
		if config == None:
			MessageWindow(_('Error during configuration'), button=None).show(5)
		self.wizard_menu.hide()
		self.list_configs()
		return None

	def _on_device_connection_failed(self, device):
		log.debug(self._connecting_config)
		self.connect_win.hide()
		title = _('Disconnected from %(net)s') % dict(net=self._connecting_config.name)
		self.connect_win = MessageWindow(title, button=None)
		def self.connect_win.eventhandler.event_stop(event):
			return None

		self.connect_win.show(timeout=3)
		self.list_configs()
		return None

	def onDeviceConnected(self, device):
		log.debug(device)
		self.on_device_connected_task.args = (device,)
		self.on_device_connected_task.start(1)

	def onDeviceConnectionFailed(self, device):
		log.debug(device)
		self.on_device_connection_failed_task.args = (device,)
		self.on_device_connection_failed_task.start(1)

	def onDeviceConnecting(self, device):
		pass

	def onDeviceDisconnected(self, device):
		pass



class NetworkWizardMenu(Menu):
	__doc__ = ' Used to fill a new config, or edit an existing one (not yet implemented) '
	def __init__(self, callback, config=None):
		self.eventhandler = WifiSelectMenuEventHandler(self)
		Menu.__init__(self, name='NetworkWizardMenu', type='network_connect', universe='setup')
		self.wn = WyNetwork()
		self._callback = callback
		self.wifi_menu = None
		self.eventhandler = WifiSelectMenuEventHandler(self)
		self.available_choices = ['options0_list', 'options1_list', 'options2_list', 'options3_list']
		def self._getitems_keywords['options0_list']():
			return self.get_item_list('options0_list')

		def self._getitems_keywords['options1_list']():
			return self.get_item_list('options1_list')

		def self._getitems_keywords['options2_list']():
			return self.get_item_list('options2_list')

		def self._getitems_keywords['options3_list']():
			return self.get_item_list('options3_list')

		self.set_items([], 'options0_list')
		self.set_items([], 'options1_list')
		self.set_items([], 'options2_list')
		self.set_items([], 'options3_list')
		self.active_list = 'options0_list'
		self.config_updaters = {'networkType': self._ask_type, 'ipConfigType': self._ask_mode, 'key': self._ask_key, 'essid': self._ask_essid, 'interface': self._ask_interface, 'authType': self._ask_key_type, 'cipher': self._ask_key_type, 'keyMgmt': self._ask_key_type, 'ipAddress': self._ask_ip_params, 'netmask': self._ask_ip_params, 'gateway': self._ask_ip_params}
		self._previous_config = None
		self._current_config = self.wn.new_config()
		log.debug('create new config')
		if config and isinstance(config, WyNetworkConfig):
			if config.is_valid():
				log.debug('editing %s (not implemented)', config.name)
				self._previous_config = config
			else:
				log.error('previous_config %s is not valid. Cancel configuration', config)
				return None
		if '802.11' not in self.wn.availables_networkType():
			log.debug('no 802.11 devices, set_ethernet()')
			self._current_config.set_ethernet()
			if self._previous_config and self._previous_config['networkType'] == '802.11':
				log.error('Editing 802.11 config but no wireless device found. Cancel configuration')
				return None
		log.debug('current_config %s', self._current_config)
		return None

	def show(self, hide_previous_menu=True):
		Menu.show(self, hide_previous_menu)
		self.start()

	def start(self):
		self.config_wizard = self.configurator()
		self.config_wizard.next()
		if self._previous_config:
			self.set_type(self._previous_config['networkType'])
		else:
			self.config_wizard.next()

	def execute_selected(self):
		self[self.active_list].selected.execute()

	def list_options(self, item, browse_list_name='options0_list'):
		self.set_items([item], 'main_list')
		for l in self.available_choices:
			self.set_items([], l)
		self.set_items(item.browse(), browse_list_name)
		self.active_list = browse_list_name

	def _wifi_callback(self, network):
		log.debug('selected network: %s', network)
		self._current_config.set_network(network)
		log.debug('config: %s', self._current_config)
		self.wifi_menu.hide()
		try:
			self.config_wizard.next()
		except StopIteration:
			log.debug('config_wizard STOP')

	def configurator(self):
		log.debug('init')
		cur_conf_configurator = self._current_config.configurator()
		cur_conf_configurator.next()
		yield None
		log.debug('start !')

	def _next_key(self):
		try:
			self.config_wizard.next()
		except StopIteration:
			log.debug('fill_config STOP')

	def _save_config(self):
		log.debug('Configuration done. saving...')
		try:
			self.wn.save_config(self._current_config)
		except Exception, e:
			PRINT_EXCEPTION(e)
		self._callback(self._current_config)

	def set_type(self, type):
		self._current_config['networkType'] = type
		if type == '802.3':
			self._current_config.set_ethernet()
			self._next_key()
		else:
			if type == '802.11':
				self.wifi_menu = WifiSelectMenu(callback=self._wifi_callback)
				self.wifi_menu.show()

	def _ask_name(self):
		def _cancel():
			log.error('User does not provide name. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_name(kbd):
			self._current_config.name = str(kbd._text)
			kbd.hide()
			self._next_key()

		if not self._current_config.name:
			pass
		text = self._current_config.name
		self.kbd = KeyboardWindow(_('Enter a name for this configuration'), text=text, confirm_action=_set_name)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_type(self):
		def _set_type(type):
			self.set_items([], 'options0_list')
			self.set_type(type)

		it = ConnectionTypeContainer(callback=_set_type, name=_('Choose your connection type'), type_='parameters', menu=self)
		self.list_options(it, 'options0_list')

	def _ask_mode(self):
		def _set_mode(mode):
			self.set_items([], 'options0_list')
			self._current_config['ipConfigType'] = mode
			self._next_key()

		it = AutoManConnectionContainer(callback=_set_mode, name=_('Choose Automatic or Manual'), type_='parameters', menu=self)
		self.list_options(it, 'options0_list')

	def _ask_interface(self):
		try:
			self.wn.autofill(self._current_config, 'interface')
		except Exception, e:
			PRINT_EXCEPTION(e)
		Task(self.config_wizard.next).start(0.20000000000000001)

	def _ask_key(self):
		def _cancel():
			log.error('User does not provide key. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_key(kbd):
			self._current_config['key'] = str(kbd._text)
			kbd.hide()
			self._next_key()

		try:
			title = _('%(authType)s key for %(essid)s') % self._current_config.config
		except Exception, e:
			title = _('key')
			PRINT_EXCEPTION(e)
		if self._previous_config and 'key' in self._previous_config:
			text = self._previous_config['key']
		else:
			text = ''
		self.kbd = KeyboardWindow(title, text=text, confirm_action=_set_key)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_essid(self):
		def _cancel():
			log.error('User does not provide essid. Cancel configuration !')
			self.kbd.hide()
			self.hide()

		def _set_essid(kbd):
			self._current_config['essid'] = str(kbd._text)
			kbd.hide()
			self._next_key()

		self.kbd = KeyboardWindow('Network Name', text='', confirm_action=_set_essid)
		self.kbd.action_buttons[4].connect(_cancel)
		self.kbd.show()

	def _ask_key_type(self):
		def _set_key_type(infos):
			self.set_items([], 'options3_list')
			self._current_config['authType'] = infos['raw_auth']
			self._current_config['keyMgmt'] = infos['raw_key_mgt']
			self._current_config['cipher'] = infos['raw_cipher']
			self._next_key()

		it = AuthTypeConnectionContainer(callback=_set_key_type, name=_('Choose key type'), type_='parameters', menu=self)
		self.list_options(it, 'options3_list')

	def _ask_ip_params(self):
		def _set_ip_params(params):
			self.set_items([], 'options1_list')
			for k, v in params.iteritems():
				self._current_config[k] = v
			self._next_key()

		keys = ('ipAddress', 'netmask', 'gateway', 'dns1', 'dns2')
		values = ['0.0.0.0'] * 5
		default_values = dict(zip(keys, values))
		if self._previous_config:
			for k in keys:
				if k in self._previous_config:
					default_values[k] = self._previous_config[k]
					continue
		it = EditNetworkConfSetupItem(callback=_set_ip_params, default_values=default_values, name=_('Configure IP parameters'), type_='parameters', menu=self)
		self.list_options(it, 'options1_list')



class WifiSelectMenu(Menu):
	__doc__ = ' Juste list availables wifi network '
	def __init__(self, callback, name='Network Connect menu'):
		self.eventhandler = WifiSelectMenuEventHandler(self)
		Menu.__init__(self, name, type='wifi_select', universe='setup')
		self.available_choices = ['main_list', 'crypto_list']
		def self._getitems_keywords['crypto_list']():
			return self.get_item_list('crypto_list')

		self.set_items([], 'main_list')
		self.set_items([], 'crypto_list')
		self._callback = callback
		self.can_scan = True
		self.on_network_appeared_task = Task(self._on_network_appeared)
		self.on_network_disappeared_task = Task(self._on_network_disappeared)
		self.wn = WyNetwork()
		self.wn.wn_net.attach(self)
		self.list_networks()

	def select(self, item, list_name=None, force_pos=False):
		ret = Menu.select(self, item, list_name, force_pos)
		if ret is not False:
			if not list_name:
				pass
		if list_name == 'main_list':
			Menu.select(self, item, 'crypto_list', force_pos)

	def execute_selected(self):
		self.selected.execute()

	def stop(self):
		self.wn.wn_net.detach(self)
		Menu.stop(self)

	def _on_network_appeared(self, dev, net):
		self.list_networks()

	def _on_network_disappeared(self, dev, net):
		self.list_networks()

	def onNetworkAppeared(self, dev, net):
		self.on_network_appeared_task.args = (dev, net)
		self.on_network_appeared_task.start(1)

	def onNetworkDisappeared(self, dev, net):
		self.on_network_disappeared_task.args = (dev, net)
		self.on_network_disappeared_task.start(1)

	def list_networks(self):
		it_list = []
		crypto_list = []
		if self.can_scan:
			for network in self.wn.get_networks():
				crypto = CryptoItem(network['essid'], '', type_='setupitem')
				if network['authType']:
					pass
				crypto.display_type = 'not_crypted'
				it = ActionItem(name=network['essid'], display_type=None, type_='setupitem', action=self._callback, args=[network])
				it.display_type = self._get_display_type(network['strength'])
				it_list.append(it)
				crypto_list.append(crypto)
			hidden_crypto = CryptoItem('hidden', '', type_='setupitem')
			hidden_crypto.display_type = 'not_crypted'
			hidden_it = ActionItem(_('Connect to an other network'), display_type=None, type_='setupitem', action=self._callback, args=[None])
			it_list.append(hidden_it)
			crypto_list.append(hidden_crypto)
			self.set_items(it_list, 'main_list')
			self.set_items(crypto_list, 'crypto_list')
		else:
			log.debug('scan blocked by pending configuration process')
		return None

	def _get_display_type(self, strength):
		strength = int(strength)
		if strength > 0 and strength <= 100:
			if strength > 80:
				return 'wifi_signal_1'
			else:
				if strength > 60:
					return 'wifi_signal_2'
				else:
					if strength > 40:
						return 'wifi_signal_3'
					else:
						if strength > 20:
							return 'wifi_signal_4'
		return 'wifi_signal_5'



